The Parametric Singleton Design Pattern
نویسندگان
چکیده
The parametric singleton design pattern combines the singleton design pattern with a parameter that enables unique creation of instances of a class. These instances are cached in a table. When a user asks for an instance with these parameters, the table is checked and instances are created conditionally. Parametric lazy instantiation causes instance creation, with the given parameters, if, and only if, it is not already in the table. Thus, the table yields the instance with optional creational effort. Lazy instantiation is not new, nor, for that matter, is the singleton design pattern. However, parametric lazy instantiation is new and so is the parametric singleton. We apply our parametric singleton design pattern to the retrieval of RMI registries bound to a given port. The goal of our system is to make sure that no two RMI registries on the same machine are listening to the same socket and to make use of the RMI registries after creation. RMI registries are used in distributed computation. Other applications include parametric resources that are countable in number, locked, when in use and released when finished. Examples include file systems, serial ports, parallel ports, video cameras, microphones and audio output streams.
منابع مشابه
Implementation Variants of the Singleton Design Pattern
We present a study of different implementation variants of the Singleton pattern and propose an intuitive definition of this pattern expressed as a first-order logic formula. We also show that our method for automatically detecting design patterns can be used to detect instances of the Singleton with respect to this definition. We also provide data on experiments with a proof-of-concept impleme...
متن کاملControlling the Destruction Order of Singleton Objects
Abstract The Singleton pattern [1] is a solution to (some of) the drawbacks of using global variables. Among its advantages is that the instance is always created prior to being referenced (this effectively solves the problem of initialization order when several interdependent instances are involved). This article examines some of the existing Singleton realizations in C++ and their drawbacks, ...
متن کاملC + + and the Perils of Double - Checked Locking ∗
Google the newsgroups or the web for the names of various design patterns, and you’re sure to find that one of the most commonly mentioned is Singleton. Try to put Singleton into practice, however, and you’re all but certain to bump into a significant limitation: as traditionally implemented (and as we explain below), Singleton isn’t thread-safe. Much effort has been put into addressing this sh...
متن کاملDynamic Envelope and Control Shading Pattern to Visual Comfort of Office Building in Tehran
This work reviews the effect of parametric programming on visual performance, daylighting and shading in office buildings in Tehran-Iran and studies their influences that help not only to reduce the glare but also to promote useful daylight illuminance through promoting visual comfort. It starts by establishing a review of the effective parameters on visual comfort indices, glare indices, and d...
متن کاملThread Specific Singletons: Handling Singleton Pattern Errors in Multi-Threaded Applications and their Variations
The use of the design patterns has been popularized with the publication of the Design Patterns book by Gamma et al. (1995). In this paper we discuss the implementation of the singleton design patterns from " error recovery " perspectives for multi-threaded applications where dynamic memory is allocated on a task by task basis. The description of the singleton pattern is straight forward but it...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Journal of Object Technology
دوره 6 شماره
صفحات -
تاریخ انتشار 2007